Fix 'assign to data in an index of' collection suggestions#152216
Fix 'assign to data in an index of' collection suggestions#152216GTimothy wants to merge 5 commits intorust-lang:mainfrom
Conversation
|
rustbot has assigned @JonathanBrouwer. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
8034656 to
2371906
Compare
|
oops, meant to title "Fix 'assign to data in an index of' map suggestions" edit for clarity: for now, these suggestions only apply to BTreeMap and HashMap. rust/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs Lines 657 to 661 in fef627b |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0fedd40 to
77c2a6e
Compare
This comment has been minimized.
This comment has been minimized.
splits the large triple suggestion into three sets them to MaybeIncorrect automatically determines the required borrowing to use.
77c2a6e to
5d997ef
Compare
|
@JonathanBrouwer, I think this is ready for review. Do I need to change anything? Thanks in advance. |
|
I'll take a look sometime in the next few days :) |
|
Reminder, once the PR becomes ready for a review, use |
- properly propose methods depending of the type relationship between the index used and the map key. - use whether key type is copy/clone to orient propositions.
|
thank you @JonathanBrouwer for your remarks. I had made a completely wrong assumptions about the types in questions. |
… and key is ok too for `insert` and `entry`
|
@rustbot ready |
fixes #150001
fixes rust-lang/rust-analyzer#16076
fixes #134917
The issues are threefold and linked:
collectionBTreeMap/HashMap suggests 3 solutions all marked asMachineApplicableThis PR:
MaybeIncorrectI think this solution may not be very elegant, expecially the key typechecking / borrowing part, but it works. I am however very open to any improvement/change :)
edit: edited to replace 'collection' with BTreeMap/HashMap'